package com.homedo.odin.solution.service.bizservice.pc;

import com.homedo.core.common.base.dto.Meta;
import com.homedo.core.common.exception.BizException;
import com.homedo.core.common.util.BeanUtils;
import com.homedo.odin.solution.model.dto.AttachmentInfoResponseBean;
import com.homedo.odin.solution.model.entity.Attachment;
import com.homedo.odin.solution.service.AttachmentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author: zhanglei
 * @date: 2018/4/9
 * @Description:
 */
@Service
public class PcAttachmentService {

    @Autowired
    private AttachmentServiceImpl attachmentService;


    /**
     * 获取附件信息
     */
    public AttachmentInfoResponseBean getAttachmentInfo(Integer id) {
        Attachment attachment = attachmentService.getAttachmentInfoById(id);
        if (attachment == null) {
            throw new BizException(Meta.CODE_404.getCode(), "没有对应的附件");
        }

        return BeanUtils.transfrom(AttachmentInfoResponseBean.class, attachment);
    }
}
